<?php
class Training_DateController extends Zendvn_Controller_Action{
	
	public function init(){
		
	}
	
	public function index8Action(){
		$city = new Zend_Date_Cities();
		$tmp = $city->getCityList();
		$hanoi = $city->City('Toronto'); // Kinh tuyen - vi tuyen
		
		$date = new Zend_Date();
		echo '<br>' . $date->getSunrise($hanoi);
		echo '<br>' . $date->getSunset($hanoi);
		
		echo '<pre>';
		print_r($tmp);
		echo '</pre>';
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index7Action(){
		$date = new Zend_Date();
		//$date->set(14,Zend_Date::HOUR);
		
		echo '<br> Now: ' . $date->get(Zend_Date::TIME_LONG);
		
		echo '<br> '. $date->compare(12,Zend_Date::HOUR); // -1 0 +1
		
		if($date->compare(12,Zend_Date::HOUR) >= 0){
			echo '<br>Shutdown Game server';
		}else{
			echo '<br>Game server running';
		}
		
		echo '<br>' . $date->equals(19,Zend_Date::HOUR);
		echo '<br>' . $date->isEarlier(21,Zend_Date::HOUR);
		
		echo '<br>' . $date->getSunrise('Asia/Ho_Chi_Minh');
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	
	public function index6Action(){
		$date = new Zend_Date();
		echo '<br>Today: ' . $date->get(Zend_Date::DATE_SHORT);
		$date->sub(100,Zend_Date::DAY);
		echo"<br> Cach 100 la: " . $date->get(Zend_Date::WEEKDAY,'vi_VN');
		
		$this->_helper->viewRenderer->setNoRender();
	} 
	
	public function index5Action(){
		$date = new Zend_Date();
		echo '<br>' . $date->get(Zend_Date::DATE_SHORT);
		$date->add(7,Zend_Date::DAY);
		echo '<br>' . $date->get(Zend_Date::DATE_SHORT);
		//===========================
		echo '<br><hr>';
		$date->setDate("2011-10-24","yyyy-MM-dd");
		echo '<br>Ngay dat quang cao: ' . $date->get(Zend_Date::DATE_SHORT);
		$date->add(7,Zend_Date::DAY);
		echo '<br>Ngay het quang cao: ' . $date->get(Zend_Date::DATE_SHORT);
		//===========================
		echo '<br><hr>';
		$date->setDate("2011-10-24","yyyy-MM-dd");
		echo '<br>Ngay dat quang cao: ' . $date->get(Zend_Date::DATE_SHORT);
		$date->add(2,Zend_Date::MONTH);
		echo '<br>Ngay het quang cao: ' . $date->get(Zend_Date::DATE_SHORT);
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index4Action(){
		$date = new Zend_Date();
		
		$date = '11.11.2000';
		$date = '2000.21.11';
		$date = '2000/11/11';
		$date = '2000:11:21';
		
		if (Zend_Date::isDate($date,"yyyy.MM.dd")) {
		    echo '<br>' . "String $date is a date";
		} else {
		    echo '<br>' .  "String $date is NO date";
		}
		

		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index3Action(){
		$date = new Zend_Date();
		
		//2.
		echo '<br>' . $date->get(Zend_Date::DATETIME_FULL,'vi_VN');
		
		
		//1. Lay thoi gian tu ngay 1-1-1970
		/*echo '<br>' . time();
		echo '<br>' . $date->get();*/
		
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function index2Action(){
		$date = new Zend_Date();
		
		//2.
		echo '<br>' . $date->get(Zend_Date::DATES,'vi_VN');
		echo '<br>' . $date->get(Zend_Date::DATES,'en_US');
		
		echo '<br>' . $date->get(Zend_Date::DATE_FULL,'vi_VN');
		echo '<br>' . $date->get(Zend_Date::DATE_FULL,'en_US');
		echo '<br>' . $date->get(Zend_Date::DATE_FULL,'de_DE');
		
		echo '<br>' . $date->get(Zend_Date::WEEK,'de_DE');
		echo '<br>' . $date->get(Zend_Date::DAY_OF_YEAR,'de_DE');
		
		
		echo '<br>' . $date->getWeek('de_DE')->toString(Zend_Date::WEEK);
		
		//1. Lay thoi gian tu ngay 1-1-1970
		/*echo '<br>' . time();
		echo '<br>' . $date->get();*/
		
		
		$this->_helper->viewRenderer->setNoRender();
	}
	
	public function indexAction(){
		date_default_timezone_set('Asia/Ho_Chi_Minh');
		echo '<br>VN: '. date("Y-M-d H:i:s");
		
		date_default_timezone_set('Asia/Tokyo');
		echo '<br>Japan: '. date("Y-M-d H:i:s");
		
		
		date_default_timezone_set('America/Los_Angeles');
		echo '<br>Los_Angeles: '. date("Y-M-d H:i:s");
		
		$this->_helper->viewRenderer->setNoRender();
	}
}